<!DOCTYPE html>
<%@ page language="java" import="com.compuvest.web.*,java.util.*,java.text.DecimalFormat" pageEncoding="UTF-8" %>

<%@ taglib uri="/WEB-INF/tld/head.tld" prefix="head" %>
<%@ taglib uri="/WEB-INF/tld/items.tld" prefix="itemstld" %>
<%@ taglib uri="/WEB-INF/tld/preference.tld" prefix="preference" %>

<jsp:useBean id="sb" class="SQLBean" scope="application"/>
<jsp:useBean id="advertShow" class="AdvertShow" scope="application"/>
<jsp:useBean id="basket" class="Basket" scope="session"/>
<%
    String http = application.getInitParameter("http");

    int categoryID = advertShow.getInt(request.getParameter("cid"), 0);
    int subcatID = advertShow.getInt(request.getParameter("sid"), 0);
    int pageNo = advertShow.getInt(request.getParameter("pg"), 0);
    int sortID = advertShow.getInt(request.getParameter("srt"), 3);

    session.setAttribute("session.categoryID", Integer.toString(categoryID));
    session.setAttribute("session.subcatID", Integer.toString(subcatID));

    // preference
    PreferenceUtil prefUtil = new PreferenceUtil(request, subcatID);

    Items tempItems = sb.getItems(subcatID, sortID, prefUtil.getContent(), pageNo);

%>
<html>
<head>
<title><%= application.getInitParameter("CompanyName") %></title>
<%@include file="./incl/scripts.txt" %>
</head>
<body>

<div id='cvbody'>

 <head:show />

 <div id='cvcont'>
  <table id='cvmain'>
  <colgroup><col width='200px'/><col width='*'/><col width='160px'/></colgroup>
  <tbody>
   <tr>
    <td id='cvleft' valign="top">

     <div id='leftmenu'></div>

    </td>
    <td id='cvcenter' align="center" valign="top">

<%
    // select advert coupon
    String advertImage = basket.getCouponShow(advertShow);
    out.write(advertImage);
%>

    <%-- Navigation --%>
    <div id='cv_nav'>
      &#8226; <a href='<%= http %>'>Home</a>
      &#8226; <a id='catName' href='<%= http %>Cats.jsp?cid=<%= categoryID %>'></a>
      &#8226; <a id='scatName' href='<%= http %>Items.jsp?cid=<%= categoryID %>&sid=<%= subcatID %>'></a>
      <b><%= tempItems.getEventTime() %></b>
    </div>

    <div id='advshow'></div>

<form name='SortForm' action='<%= http %>Items.jsp' method='POST'>
<input type='hidden' name='pg' value='0'/>
<input type='hidden' name='cid' value='<%= categoryID %>'/>
<input type='hidden' name='sid' value='<%= subcatID %>'/>
<%= prefUtil.getHiddenTags() %>

<itemstld:show
 categoryID='<%= categoryID %>'
 subcategoryID='<%= subcatID %>'
 pageNo='<%= pageNo %>'
 pageUrl='<%= http + "Items.jsp?cid=" + categoryID + "&sid=" + subcatID + prefUtil.getLink() %>'
 reseller='<%= basket.getReseller() %>'
 items='<%= tempItems %>'
 sortID='<%= sortID %>'
/>

</form>

    </td>
    <td id='cvright' valign="top">

     <div id='advright'></div>

<preference:show
 pageUrl='<%= http + "Items.jsp?cid=" + categoryID + "&sid=" + subcatID + "&srt=" + sortID %>'
 preferenceList='<%= tempItems.getPreference() %>'
 popUrl='<%= prefUtil.getLink() %>'
 popData='<%= prefUtil.getContent() %>'
/>

    </td>
   </tr>
  </tbody>
  </table>
 </div>

 <div id='cvfoot'></div>
</div>

</body>
<script type="text/javascript">
  window.addEvent('domready', function() {
    new LeftMenu({gid:<%= categoryID %>,sid:<%= subcatID %>,data:<%= advertShow.getLeftMenu() %>});
    new AdvertShow({data:<%= advertShow.getItemsSubcategoryPage("" + subcatID) %>,cols:5,count:10});
  });
</script>
</html>
